package com.nacos.druid;

import com.alibaba.druid.pool.DruidDataSource;

import java.sql.SQLException;

/**
 * @author: li chao
 * @Desc:
 * @create: 2024-07-01 09:35
 **/
public class test001 {
    public static void main(String[] args) {
        DruidDataSource ds = new DruidDataSource();
        ds.setBreakAfterAcquireFailure(true);
        ds.setConnectionErrorRetryAttempts(1); //sql username
        ds.setUsername("root"); //error password
        ds.setPassword("kiqoiqueoipqu");
        ds.setMaxWait(300000L);
        ds.setMaxActive(3);
        ds.setDriverClassName("com.mysql.cj.jdbc.Driver");
        StringBuilder sbUrl = new StringBuilder(); //sql ip
        sbUrl.append("jdbc:mysql://").append("127.0.0.1").append(":").append("3306");
        ds.setUrl(sbUrl.toString());
        try {
            ds.getConnection();
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }
}
